package exfist;

import java.awt.Point;
import java.awt.image.BufferedImage;

public class Moves 
{
	SpriteCache sc=new SpriteCache();
	/**
	 * default Constructor
	 *
	 */
	protected Moves()
	{
	}
	/**
	 * takes in an array of BufferedImages and populates them with the images in a given folder
	 * @param bf the array of BufferedImage
	 * @param loc the location of the imgs to be used
	 * @param rb is it the red folder or blue folder
	 */
	protected void set_Imgs(BufferedImage[] bf,String loc,String rb)
	{
		for(int i=0;i<bf.length;i++)
		{
			bf[i]=sc.getSprite(loc+rb+"/"+(i+1)+".gif");
		}
	}
	/**
	 * takes in an array of BufferedImages and populates them with the images in a given folder,but in reverse order
	 * @param bf the array of BufferedImage
	 * @param loc the location of the imgs to be used
	 * @param rb is it the red folder or blue folder
	 */
	protected void set_ImgsRev(BufferedImage[] bf,String loc,String rb)
	{
		for(int i=bf.length;i>=1;i--)
		{
			bf[bf.length-i]=sc.getSprite(loc+rb+"/"+(i)+".gif");
		}
	}
	/**
	 * Takes an array of empty nodes and populates them
	 * @param nd the node
	 * @param bf the sprite associate with the node
	 * @param name the name of the node (movename + number of node)
	 * @param vec the movement vector for the move in question
	 * @param hittable can the player be hit or not
	 */
	protected void set_Nodes(Node[] nd,BufferedImage[] bf,String name,Point vec,boolean hittable)
	{
		for(int i=0;i<nd.length;i++)
		{
			nd[i] = new Node(name+i,bf[i],vec,hittable);
		}
	}
	/**
	 * Takes an array of empty nodes and populates them within a given range
	 * @param nd the node
	 * @param bf the sprite associate with the node
	 * @param name the name of the node (movename + number of node)
	 * @param vec the movement vector for the move in question
	 * @param hittable can the player be hit or not
	 * @param start the first node to be populated
	 * @param end the last node to be populated
	 */
	protected void set_Nodes(Node[] nd,BufferedImage[] bf,String name,Point vec,boolean hittable,int start,int end) //not happy with length of args
	{
		for(int i=start;i<=end;i++)
		{
			nd[i] = new Node(name+i,bf[i],vec,hittable);
		}
	}
	/**
	 * Arranges an array of nodes into a tree branch
	 * @param state the tree
	 * @param nd the array of nodes
	 */
	protected void populate_Branch(State_Tree state,Node[] nd)
	{
		for(int i=0;i<(nd.length-1);i++)
		{
			state.addNode(nd[i], nd[i+1]);
		}
	}
}
